import jade.core.AID;
import jade.core.Agent;
import jade.lang.acl.ACLMessage;

import java.io.IOException;
import java.util.Iterator;
import java.util.Vector;


public class AgentPP extends Agent
{
protected void setup()
{
	//citesc liniile scenariului
Vector<String> linii = new Vector<String>();
try {
	  linii = ReadFile.read(BlackBoard._TXT_PATH+"scenario.txt");
	  
    }catch(IOException e1) {System.out.println("File not found!");}	


Iterator<String> it = linii.iterator();
String linie;

int index=0;

//trimit fiecare linie
while (it.hasNext()) {
	linie = it.next();	
    
	    sendMessage(linie+"|"+index);
index++;
//if(index==linii.size())
//{System.out.println("Nu mai sunt linii de analizat"); 
//doDelete();}
}//end while
 
	}

//trimiterea unui mesaj
	private void sendMessage(String linie){
		AID r=new AID ("AgentAnLexicala@"+getHap(),AID.ISGUID);
		ACLMessage msg=new ACLMessage(ACLMessage.REQUEST);
		msg.addReceiver(r);		
		msg.setContent(linie);
		this.send(msg);
			
	}
	
protected void takeDown() {
//	 Printout a dismissal message
	System.out.println(this.getLocalName()+" terminating");
	}
}
